﻿using MediatR;
using PublicClass;
using S.Eartag.Domain.Model;
using S.Eartag.Infrastructure.Interface;
using S.Eartag.Read.API.Application.Command.SheepFileConditionCommand;

namespace S.Eartag.Read.API.Application.CommandHandlers.SheepFileConditionCommandHandler
{
    public class SheepFileConditionarDescendantfileCommandHandler : IRequestHandler<SheepFileConditionarDescendantfileCommand, List<SheepFile>>
    {
        private readonly ISheepFileRepository sheepFileRepository;

        public SheepFileConditionarDescendantfileCommandHandler(ISheepFileRepository sheepFileRepository)
        {
            this.sheepFileRepository = sheepFileRepository;
        }

        public async Task<List<SheepFile>> Handle(SheepFileConditionarDescendantfileCommand request, CancellationToken cancellationToken)
        {
            var res = sheepFileRepository.All().Result.Where(x => x.sheepType == (SheepType.后裔));
            return res.ToList();
        }
    }
}
